import {BaseService} from 'egg-cool-service';

/**
 * 商品-标签
 */
export default class GoodsTagService extends BaseService {

    /**
     * 新增
     * @param param
     */
    async add (param) {
        await this.getRepo ().goods.Tag.save (param);
    }

    /**
     * 分类排序
     * @param params
     */
    async order (params) {
        for (const e of params) {
            await this.getRepo ().goods.Tag.update (e.id , e);
        }
    }

    /**
     * 获得分类菜单
     */
    async list () {
        const list = await this.nativeQuery (`
        SELECT
            *
            FROM
        goods_tag a
        WHERE
        1 = 1
        ORDER BY
        a.orderNum ASC`);
        return list;
    }

    async info (id , entity) {
        let item = await entity.findOne ({id});
        return item;
    }

}
